<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<!-- 1、js随机
// 用 js 实现随机选取 10-100 之间的 10 个数字，存入一个数组，去重后求和（保证这 10 个数字不能出现重复）
要求：去重不能使用 Set -->

<body>
    <div>test14-1</div>
    <script>
        let arr = [];
        let b
        function random(start, end) {
            for (let i = 0; i < 10; i++) {
                let num = Math.floor(start + Math.random() * (end - start));
                arr.push(num)
            }
            b = arr.filter((i, index) => arr.indexOf(i) === index)
            while (b.length < 10) {
                let num1 = Math.floor(start + Math.random() * (end - start));
                if (b.indexOf(num1) == -1) {
                    b.push(num1);
                }
            }
            return b
        }

        console.log(random(10, 100))

    </script>
</body>

</html>